package com.smallpineapple.turing.service.guest.impl;

import com.smallpineapple.turing.dao.HistoryDao;
import com.smallpineapple.turing.entity.History;
import com.smallpineapple.turing.enums.MyCustomizeErrorCode;
import com.smallpineapple.turing.exception.CustomizeException;
import com.smallpineapple.turing.service.guest.IntroductionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Jack
 * @date 2019-06-27-17:06
 */
@Service
public class IntroductionServiceImpl implements IntroductionService {

    @Autowired
    HistoryDao historyDao;

    @Override
    public History getIntroduction() {
        List<History> histories = historyDao.findAll();
        if(histories == null | histories.size() == 0){
            throw new CustomizeException(MyCustomizeErrorCode.HISTORY_NOT_FOUND);
        }
        return histories.get(0);
    }
}
